
import React, { Component } from 'react'
import eventBus from '../../../utils/eventBus';
import myPubSub from '../../../utils/myPubSub';

export default class index extends Component {

  chuanFn=()=>{
    eventBus.$emit("chuan","hello，兄弟");

  }

  chuanFn02=()=>{
    myPubSub.publish("chuanB","hello，我是你哥");
  }

  render() {
    return (
      <div>
        <h1>子组件A</h1>
        <input type="button" value="传给B（使用自定义事件机制）" onClick={this.chuanFn} />
        <input type="button" value="传给B(使用PubSub）" onClick={this.chuanFn02} />
      </div>
    )
  }
}
